def is_valid_sequence(s):
    stack = []
    for c in s:
        if c in '([{<':
            stack.append(c)
        elif c in ')]}>':
            if not stack:
                return False
            if c == ')' and stack[-1] == '(':
                stack.pop()
            elif c == ']' and stack[-1] == '[':
                stack.pop()
            elif c == '}' and stack[-1] == '{':
                stack.pop()
            elif c == '>' and stack[-1] == '<':
                stack.pop()
            else:
                return False
    return not stack


print(is_valid_sequence(input('Введите скобочную последовательность: ')))
